package com.lzk.策略模式.使用策略模式改进代码;

import com.lzk.策略模式.使用策略模式改进代码.flyBehaviorImpl.NoFlyBehavior;

/**
 * @author: zhongkui 1365693530@qq.com
 * @Date: 2024/9/8
 */
public class Main {
    public static void main(String[] args) {
        WildDuck wildDuck = new WildDuck();
        System.out.println("野鸭子");
        wildDuck.fly();
        ToyDuck toyDuck = new ToyDuck();
        System.out.println("玩具鸭");
        toyDuck.fly();
        PekingDuck pekingDuck = new PekingDuck();
        System.out.println("北京鸭");
        pekingDuck.fly();


        //动态改变某个对象的行为 北京鸭不能飞翔
        pekingDuck.setFlyBehavior(new NoFlyBehavior());
        System.out.println("北京鸭");
        pekingDuck.fly();
    }
}
